package com.yonyou.liulzha.controller;

import com.yonyou.ucf.mdd.ext.base.BaseController;
import com.yonyou.ucf.mdd.ext.util.ResultMessage;
import com.yonyou.liulzha.service.LiulzhaExpenseCardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;


@RestController
@RequestMapping("/liulzhaExpenseCard")
public class LiulzhaExpenseCardController extends BaseController {

    @Autowired
    public LiulzhaExpenseCardService expenseCardService;

    /**
     * 根据 项目 获取经费卡 和 占用（请购单编辑后使用）
     *
     * @param params
     * @param request
     * @param response
     */
    @PostMapping("/getExpenseCardByProject")
    public void getExpenseCardByProject(@RequestBody Map<String, Object> params, HttpServletRequest request, HttpServletResponse response) {
        try {
            Map res = expenseCardService.getExpenseCardByProject((String) params.get("project"), (String) params.get("orgId"));
            renderJson(response, ResultMessage.data(res));
        } catch (Exception e) {
            e.printStackTrace();
            renderJson(response, ResultMessage.error(e.getMessage()));
        }
    }

}
